<?php if(!defined('ROOT_PATH')) exit('Access Denied');?><dl class="Tabs">
  <dt id="TagsTabs"><a href="#tabTagAdd" class="select">列表</a> <a href="#tabTagList">添加</a></dt>
  <dd id="tabTagAdd" style="display: block; ">
    <p class="operate">操作: <a href="#" onclick="checkAll('list-tag'); return false;">选择全部</a> , <a href="#" onclick="uncheckAll('list-tag'); return false;">全部不选</a>&nbsp;&nbsp;&nbsp;
      选择项: <a href="#" onclick="if(confirm('确定删除?')){metaDelete();} return false;">删除</a> </p>
    <table class="list-table" id="list-tag">
      <colgroup>
      <col width="25">
      <col width="25">
      <col width="500">
      <col width="100">
      <col width="250">
      </colgroup>
      <thead>
        <tr>
          <th class="radius-topleft"> </th>
          <th>ID</th>
          <th>栏目名称</th>
          <th>所属板块</th>
          <th class="radius-topright">操作</th>
        </tr>
      </thead>
      <tbody>
      <?php if(is_array($catdata)) foreach($catdata AS $vlaue) { ?>
      <tr id="tag-<?php echo $vlaue["id"];?>">
      
      <td><input type="checkbox" value="<?php echo $vlaue["id"];?>" name="cid[]"></td>
        <td><?php echo $vlaue["id"];?></td>
        <td><a href="#" onclick="ajaxLoad('/admin.php/Admin_Categories/edit/cid/<?php echo $vlaue["id"];?>');return false;"><?php echo $vlaue["name"];?></a></td>
        <td><?php echo $vlaue["module"];?></td>
        <td>
        <a href="#" onclick="ajaxLoad('/admin.php/Admin_Categories/add/id/<?php echo $vlaue["id"];?>');return false;">添加内容</a>
        <a href="#" onclick="ajaxLoad('/admin.php/Admin_Categories/edit/cid/<?php echo $vlaue["id"];?>');return false;"> 编辑栏目</a>
        <a onclick="if(confirm('确定删除?')){metaDelete();} return false;" href="#" > 删除栏目</a>
        </td>
      </tr>
      <?php } ?>

      </tbody>
      
    </table>
  </dd>
  <dd id="tabTagList" style="display: none; ">
    <form action="/admin.php/Admin_Categories/Add" method="post" id="add-categories">
      <ul id="add-post-option">
        <li>
          <label  class="add-post-label">栏目名称：</label>
          <input type="text"  name="name" value="" class="add-post-text" />
        </li>
        <li>
          <label  class="add-post-label">是否隐藏：</label>
          <input type="radio" checked="checked" value="1" name="hide">正常显示
  <input type="radio" value="0" name="hide">隐藏栏目
        </li>
         <li>
          <label  class="add-post-label">栏目分类：</label>
          <select name="fid" size="1" class="add-post-select">
            <option value="0" selected="selected">---顶级分类---</option>
            <?php if(is_array($catdata)) foreach($catdata AS $vlaue) { ?>
            <option value="<?php echo $vlaue["id"];?>"><?php echo $vlaue["name"];?></option>
            <?php } ?>

          </select>
        </li>
        <li>
          <label  class="add-post-label">关键字：</label>
          <textarea  class="add-post-textarea" name="keywords"  autocomplete="off"></textarea>
        </li>
        <li>
          <label  class="add-post-label">描述：</label>
          <textarea class="add-post-textarea" name="description"  autocomplete="off"></textarea>
        </li>
        <li>
          <label  class="add-post-label"></label>
          <input type="submit" name="submit" id="submit" value="添加栏目" />
        </li>
      </ul>
    </form>
  </dd>
</dl>
<script>
Tabs(document.getElementById('TagsTabs'), 'select', 0);
$('#add-categories').ajaxForm({
beforeSubmit: function(){
$("#submit").attr('disabled',true);
},
success: function(data){
if(data=='ok!') {
showMessage('添加成功！','tips');
$("#submit").attr('disabled',false);
ajaxLoad('/admin.php/Admin_Categories');
} else {
showMessage('添加失败！','error');
}
$("#submit").attr('disabled',false);
}});

function metaDelete() {
$("#list-tag input:checked").each(function(){
$.post(
'/admin.php/Admin_Categories/Del',
{'cid':$(this).val()},
function(response){
if(!response){
showMessage(response,'tips');
ajaxLoad('/admin.php/Admin_Categories');
}
},
"json"
);
});

}
</script>